<script>
  // 3 7 4 1 undefined 5
  // 3 7 4 1 2 5 
  const first = () =>
    new Promise((resolve, reject) => {
      console.log(3);
      let p = new Promise((resolve, reject) => {
        console.log(7);
        setTimeout(() => {
          console.log(5);
          resolve(6);
        }, 0);
        resolve(1);// 这里执行完, p 状态变为了成功, 成功的结果值为 1
      });
      resolve(2);// 这里执行完, first 返回的 promise 状态变为了成功
      p.then((arg) => {
        console.log(arg);// 1
      });
    });

  first().then(
    (arg) => {
    console.log(arg);// 2
  });
  console.log(4);
</script>
